/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package CalculationManager;

import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;

/**
 *
 * @author jfernan
 */

@RunWith(JMock.class)
public class CalculationManagerTest_jmock {

   private IMultiplicationService multiplicatorServiceMock;
    private CalculationManager calculationManager;

         Mockery context = new JUnit4Mockery();

    @Before
    public void setUp() throws Exception {
        multiplicatorServiceMock = context.mock(IMultiplicationService.class);
        calculationManager = new CalculationManager();
        calculationManager.setMultiplicatorService(multiplicatorServiceMock);
    }

    @Test
    public void testCalculationManager() {
        final Integer oneProductPrice = 12;
        final Integer amount = 3;
        Integer reduction = 6;


           context.checking(new Expectations() {{
            oneOf (multiplicatorServiceMock).multiply(oneProductPrice, amount);
            will(returnValue( oneProductPrice * amount ));

        }});

        //object to be tested
        Integer result =
                calculationManager.calculatePrice(oneProductPrice, amount, reduction);

        assertEquals(result, Integer.valueOf( oneProductPrice * amount - reduction) );

      
    }

}